import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;


public class ASINKeyword {
private String ASIN;
private String productName;
private String by;
private double price;
private double shipPrice;
private String productDescription;
private int buyingChoices;
private long item_no;

public long getItem_no() {
	return item_no;
}
public void setItem_no(long item_no) {
	this.item_no = item_no;
}
public String getASIN() {
	return ASIN;
}
public void setASIN(String aSIN) {
	ASIN = aSIN;
}
public String getProductName() {
	return productName;
}
public void setProductName(String productName) {
	this.productName = productName;
}
public String getBy() {
	return by;
}
public void setBy(String by) {
	this.by = by;
}
public double getPrice() {
	return price;
}
public void setPrice(double price) {
	this.price = price;
}
public double getShipPrice() {
	return shipPrice;
}
public void setShipPrice(double shipPrice) {
	this.shipPrice = shipPrice;
}
public String getProductDescription() {
	return productDescription;
}
public void setProductDescription(String productDescription) {
	this.productDescription = productDescription;
}
public int getBuyingChoices() {
	return buyingChoices;
}
public void setBuyingChoices(int buyingChoices) {
	this.buyingChoices = buyingChoices;
}

public static boolean checkDuplicate(Connection connection,String asin) throws SQLException{
	
	PreparedStatement ps = connection
			.prepareStatement("select ASIN from ASINKeyword  where ASIN=?");
	ps.setString(1, asin);
	ResultSet rs= ps.executeQuery();
	
	
  return rs.first();
}
public static int insert(Connection connection, ASINKeyword asinKeyword) throws SQLException{

	PreparedStatement ps = connection
			.prepareStatement("insert into ASINKeyword(ASIN,productName,ASINKeyword.by,price,shipPrice,productDescription,buyingChoices,item_no) values (?,?,?,?,?,?,?,?)");
	ps.setString(1, asinKeyword.getASIN());
	ps.setString(2,asinKeyword.getProductName());
	ps.setString(3,asinKeyword.getBy());
	ps.setDouble(4, asinKeyword.getPrice());
	ps.setDouble(5, asinKeyword.getShipPrice());
	ps.setString(6, asinKeyword.getProductDescription());
	ps.setInt(7, asinKeyword.getBuyingChoices());
	ps.setLong(8, asinKeyword.getItem_no());
	
	int rs=  ps.executeUpdate();
	connection.commit();
	
  return rs;

}
}
